{% extends layout %}

{% block content %}
<script>
    var FPH = new FormPageHelper({ModelName:'Menu',entity: '{{entity|dump(0)|safe}}' });
</script>
<script>
    $(function(){
        var FVSettings ={
            title: {
                row: '.col-sm-6',
                validators: {
                    notEmpty: {
                        message: '标题不能为空'
                    }
                }
            },
            url: {
                row: '.col-sm-6',
                validators: {
                    notEmpty: {
                        message: '链接不可为空'
                    }
                }
            },
            sort: {
                row: '.col-sm-6',
                validators: {
                    notEmpty: {
                        message: '排序不可为空'
                    },
                    integer: {
                        message: '排序必须为整数'
                    }
                }
            }
        };
        FPH.initFormValidation(FVSettings);
        FPH.initFormData();
    });
</script>
<div class="row">
    <div class="col-xs-12">
        <div class="box box-warning">
            <div class="box-header with-border">
                <h3 class="box-title">{% if entity._id %}修改{%else%}新增{%endif%}菜单</h3>
            </div>
            <form id="MainForm">
                {% if entity._id %}
                    <input type="hidden" name="_id" value="{{entity._id}}" />
                {% endif %}
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-12"><span style="color:red;">*</span>菜单名称</label>
                        <div class="col-sm-6">
                            <input type="text" name="title" class="form-control">
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-12"><span style="color:red;">*</span>菜单地址</label>
                        <div class="col-sm-6">
                            <input type="text" name="url" class="form-control">
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-12">菜单图标</label>
                        <div class="col-sm-6">
                            <input type="text" name="icon" class="form-control">
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-12"><span style="color:red;">*</span>菜单排序</label>
                        <div class="col-sm-6">
                            <input type="text" name="sort" class="form-control">
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-12">所属菜单</label>
                        <div class="col-sm-6">
                            <select name="menu" class="form-control">
                                <option selected="selected" value="">-</option>
                                {% for rootmenu in menus -%}
                                    <option value="{{rootmenu._id.toString()}}">{{rootmenu.title}}</option>
                                {%- endfor %}
                            </select>
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>
                    <div class="col-md-12">
                        <input type="button" class="btn btn-danger submit" style="margin-right:30px; width: 60px" value="保存" />
                        <input class="btn btn-default cancel" style="width:60px" type="button" value="返回" />
                    </div>
                    <div class="clearfix"></div>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}